package HttpBean.Request.RequestImpl;

import HttpBean.Request.RequestEntity;
import HttpBean.Request.RequestLine;

import java.io.BufferedReader;
import java.io.IOException;

public class RequestPostReadBufferImpl extends RequestGetReadBufferImpl {
    RequestEntity requestEntity;
    public RequestPostReadBufferImpl(BufferedReader reader, RequestLine requestLine) throws IOException {
        super(reader, requestLine);
        System.out.println(super.toString());
        int len = Integer.valueOf(super.getRequestHead().map.get("Content-Length"));
        StringBuilder str = new StringBuilder();
        while (len>0){
            str.append((char)(reader.read()));
            len--;
        }
        this.requestEntity = new RequestEntity(str.toString());
    }

    @Override
    public String toString() {
        return "RequestPostImpl{" +
                "requestHead=" + super.getRequestHead().toString() +
                ", requestLine=" + super.getRequestLine().toString() +
                ", requestEntity=" + requestEntity.toString() +
                '}';
    }
}
